#include<bits/stdc++.h>
using namespace std;
#define inf 0x3f3f3f3f
const int N=1e5+1;
inline int read(){
    int f=1,x=0;char c=getchar();
    while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
    while(isdigit(c)){x=x*10+c-'0';c=getchar();}
    return f*x;
}
struct sss{
    int l,r;
}cur[N],ban[N];
int T,n,m,L,V,d[N],v[N],a[N],place[N],ans,unl[N],unr[N],idx;
bool cmp1(sss a,sss b){
    if(a.l==b.l)return a.r<b.r;
    return a.l<b.l;
}
bool cmp2(sss a,sss b){
    if(a.r==b.r)return a.l<b.l;
    return a.r<b.r;
}
bool div(){
    for(int i=1;i<=n;i++)if(a[i]<0)return 0;
    return 1;
}
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    T=read();
    while(T--){
        ans=0;
        n=read();m=read();L=read();V=read();
        for(int i=1;i<=n;i++){
            d[i]=read();v[i]=read();cin>>a[i];
            cur[i].l=-1;cur[i].r=-1;
            if(a[i]<0){
                if(v[i]<=V)continue;
                cur[i].l=d[i];
                double t=(v[i]-V)*1.0/(-a[i]);t-=0.001;//
                double x=0.5*a[i]*t*t+v[i]*t;
                cur[i].r=min(L,(int)floor(d[i]+x));
            }else if(a[i]==0){
                if(v[i]>V)cur[i].l=d[i],cur[i].r=L;
            }else{
                double t=(V-v[i])*1.0/a[i];t+=0.001;//
                double x=0.5*a[i]*t*t+v[i]*t;
                if(d[i]+x<=L*1.0){
                    cur[i].l=(int)floor(d[i]+x);
                    cur[i].r=L;
                }
            }
        }
        for(int i=1;i<=m;i++)place[i]=read();
        for(int i=1;i<=n;i++){
            int nxt=*lower_bound(place+1,place+m+1,cur[i].l);
            if(nxt<=0||nxt>L)continue;
            if(nxt<=cur[i].r)ban[++idx]={cur[i].l,cur[i].r},ans++;
        }
        printf("%d ",ans);
        if(div()){
            if(ans==0)cout<<m<<endl;
            else cout<<m-1<<endl;
            continue;
        }
        int minl=inf,minr=inf;
        sort(ban+1,ban+idx+1,cmp1);minl=ban[1].l;
        int j=1;n=idx;
        for(int i=1;i<=m;i++){
            while(j<=n&&ban[j].l<=place[i])j++;
            unl[i]=(j<=n)?ban[j].l:inf;
            if(j>n)j--;
        }
        sort(ban+1,ban+idx+1,cmp2);minr=ban[1].r;
        j=1;
        for(int i=1;i<=m;i++){
            while(j<=n&&ban[j].l<=place[i])j++;
            unr[i]=(j<=n)?ban[j].r:inf;
            if(j>n)j--;
        }
        int need=0;
        for(int i=1;i<=m;i++){
            while(i<=m&&(place[i+1]<=minr&&place[i+1]>=minl))i++,need++;
            minl=unl[i];
            minr=unr[i];
            //cout<<i<<' '<<place[i]<<' '<<minl<<' '<<minr<<endl;
            if(minl==inf){
                need+=m-i;
                break;
            }
        }
        printf("%d\n",need);
    }
}
